-
-
Notifications
You must be signed in to change notification settings - Fork 54
Implement PEP 526 Variable Annotations Syntax #16
Conversation
Since this is just a backport of the corresponding Python 3.6 code I'm going to merge this mostly based on trust. I'll iterate once I've got most things working again. |
Never mind I don't have commit access to this repo, and David's out this week. :-( |
@gvanrossum Did I understand you correct? I am now testing this and will update PRs (here and at mypy) soon. |
Those behaviors sound okay. I am now testing too. Two administrative nits I found:
|
OK, will do this
There is also a third option to keep both (see my comment at mypy PR) |
This is technically a breaking interface change, so I'm going to bump a major version number.
This isn't compatible with the current mypy, so I'll need to wait until python/mypy#2131 is pushed to PyPI before releasing this. |
@ddfisher I thought that you are supposed to review and merge python/mypy#2131 That one should work with both old and new versions of typed_ast. |
Yep! That's the plan. I just wanted to make a note here about the need to wait for a mypy release before releasing this. |
Actually, I chatted with Guido a bit about this, and we'd like to remove that dependency problem. Here's how that could be done: instead of putting the assignment type annotation in the same field as the type comment, leave the type comment field as is and add a new one for the type annotation. This is similar to how function annotations/type comments are handled. Also, I think this would get rid of the need for the new_syntax field, which would be a nice simplification. Would you mind making these changes? |
OK, I will do this. I will push commits here and to mypy PR together with implementing your comments (not sure that I will have time to do all this today). |
Thanks! |
@ddfisher I updated all the three PRs (here, mypy, and typeshed) taking into account your comments. |
It turns out that importing yourself in setup.py is a bad idea. See e.g.: http://stackoverflow.com/questions/2058802/how-can-i-get-the-version-defined-in-setup-py-setuptools-in-my-package
Had to make some minor tweaks, but this looks good now. Thanks! |
Depends on python/typed_ast#16 for the new syntax, but is backwards compatible otherwise.
Previously we returned a string (bytes) object.
Issue python#16: accept arbitrary buffer-compatible objects
@ddfisher @gvanrossum @JukkaL
Here is an implementation of the PEP 526 syntax with minimal changes in typed_ast API. The only externally visible change is:
This requires a tiny change to
mypy/fastparse.py
, there is an accompanying PR to mypy with this change.